<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="./echarts.min.js"></script>
  </head>
  <body>
    <div class="main" style="width: 800px; height: 400px"></div>
    <script>
      function getRandomValues() {
        const values = [];
        for (let i = 0; i < 7; i++) {
          values.push(Math.floor(Math.random() * 100 + 50));
        }
        return values;
      }

      const myEcharts = echarts.init(document.querySelector(".main"));

      var option = {
        xAxis: {
          data: [
            "星期一",
            "星期二",
            "星期三",
            "星期四",
            "星期五",
            "星期六",
            "星期日",
          ],
        },
        yAxis: {},
        tooltip: {}, // 提示
        toolbox: {
          feature: {
            saveAsImage: {},
            dataView: {},
          },
        },
        series: [
          {
            name: "条状图",
            type: "bar",
            data: getRandomValues(),
          },
          {
            name: "折线图",
            type: "line",
            data: getRandomValues(),
          },
          {
            name: "饼状图",
            type: "pie",
            data: [
              { name: "xxx", value: 111 },
              { name: "yyy", value: 222 },
              { name: "zzz", value: 333 },
            ],
            // 饼图半径
            radius: 50,
            // 圆心坐标
            center: [650, 50],
          },
        ],
      };

      myEcharts.setOption(option);
    </script>
  </body>
</html>
